<%--
  Created by IntelliJ IDEA.
  User: 75880
  Date: 2024/8/17
  Time: 8:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增图书</title>
    <%
        String base = request.getContextPath() + "/";
        String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + base;
    %>
    <base href="<%=url%>">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("[type='button']").click(function () {
                var bookName = $("[name='bookName']").val();
                var bookAuthor = $("[name='bookAuthor']").val();
                var bookPublish = $("[name='bookPublish']").val();
                var bookPage = $("[name='bookPage']").val();
                var bookPrice = $("[name='bookPrice']").val();
                var createDate = $("[name='createDate']").val();
                $.get("book/insert", {
                        "bookName": bookName,
                        "bookAuthor": bookAuthor,
                        "bookPublish": bookPublish,
                        "bookPage": bookPage,
                        "bookPrice": bookPrice,
                        "createDate": createDate
                    },
                    function (boo) {
                        if (boo) {
                            alert("添加成功")
                        } else {
                            alert("添加失败")
                        }
                        window.location.href = "index.jsp"
                    })
            })
        });


    </script>
</head>
<body>
书名:<input type="text" name="bookName"><br>
作者:<input type="text" name="bookAuthor"><br>
出版社:<input type="text" name="bookPublish"><br>
页数:<input type="text" name="bookPage"><br>
价格:<input type="text" name="bookPrice"><br>
创建时间:<input type="date" name="createDate"><br>
<input type="button" value="新增">
</body>
</html>
